package com.company.project.controller.ldjsc.srfb;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.company.project.entity.ldjsc.snyj.JscSnyjMtEntity;
import com.company.project.entity.ldjsc.srfb.JscwzSrfbXlylEntity;
import com.company.project.service.ldjsc.srfb.JscwzSrfbXlylService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.company.project.common.utils.DataResult;





/**
 *
 *
 * @author wenbin
 * @email *****@mail.com
 * @date 2025-08-20 15:09:17
 */
@Controller
@RequestMapping("/sxzy")
public class JscwzSrfbXlylController {
    @Autowired
    private JscwzSrfbXlylService jscwzSrfbXlylService;


    @ApiOperation(value = "训练演练")
    @GetMapping("/jsc-dd-zt/JscXlylLb2")
    @ResponseBody
    public DataResult findListByPage(JscwzSrfbXlylEntity jscwzSrfbXlyl){
        LambdaQueryWrapper<JscwzSrfbXlylEntity> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.eq(JscwzSrfbXlylEntity::getTitle, jscwzSrfbXlyl.getTitle());
        queryWrapper.orderByDesc(JscwzSrfbXlylEntity::getUpdate_time);

        if (jscwzSrfbXlyl.getMidgard_offset() != null){
            jscwzSrfbXlyl.setMidgard_page(1);
        }
        IPage<JscwzSrfbXlylEntity> iPage = jscwzSrfbXlylService.page(jscwzSrfbXlyl.getQueryPage(), queryWrapper);
        List<JscwzSrfbXlylEntity> records = iPage.getRecords();


        // 构造所需的数据结构
        List<String> columnNames = Arrays.asList(
                "id",
                "model",
                "type",
                "title",
                "sub_title",
                "time",
                "place",
                "scope",
                "dress",
                "equipment",
                "characteristic",
                "form",
                "detail",
                "attachment",
                "source",
                "date",
                "index_name",
                "time_type",
                "update_time"
        );

        Map<String, Object> result = new HashMap<>();
        result.put("columnNames", columnNames);
        result.put("value", records);

        return DataResult.success(result);
    }




}
